home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++)))) RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWFile - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss #include <rw/rwfile.h> RWFile f("filename"); DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn Class RRRRWWWWFFFFiiiilllleeee encapsulates binary file operations using the Standard C stream library (functions ffffooooppppeeeennnn(((()))), ffffrrrreeeeaaaadddd(((()))), ffffwwwwrrrriiiitttteeee(((()))), eeeettttcccc....). This class is based on class PPPPFFFFiiiilllleeee of the IIIInnnntttteeeerrrrvvvviiiieeeewwwwssss CCCCllllaaaassssssss LLLLiiiibbbbrrrraaaarrrryyyy (1987, Stanford University). The member function names begin with upper case letters in order to maintain compatibility with class PPPPFFFFiiiilllleeee . Because this class is intended to encapsulate bbbbiiiinnnnaaaarrrryyyy operations, it is important that it be opened using a binary mode. This is particularly important under MS-DOS -- otherwise bytes that happen to match a newline will be expanded to (carriage return, line feed). PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee None PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss RRRRWWWWFFFFiiiilllleeee(const char* filename, const char* mode = 0); Construct an RRRRWWWWFFFFiiiilllleeee to be used with the file of name ffffiiiilllleeeennnnaaaammmmeeee and with mode mmmmooooddddeeee. The mode is as given by the Standard C library function ffffooooppppeeeennnn(((()))). If mmmmooooddddeeee is zero (the default) then the constructor will attempt to open an existing file with the given filename for update (mode "rrrrbbbb++++"). If this is not possible, then it will attempt to create a new file with the given filename (mode "wwwwbbbb++++"). The resultant object should be checked for validity using function iiiissssVVVVaaaalllliiiidddd(((()))). ~RRRRWWWWFFFFiiiilllleeee(); Performs any pending I/O operations and closes the file. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss const char* AAAAcccccccceeeessssssss(); Returns the access mode with which the underlying FFFFIIIILLLLEEEE**** was opened. PPPPaaaaggggeeee 1111 RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++)))) RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++)))) void CCCClllleeeeaaaarrrrEEEErrrrrrrr(); Reset error state so that neither EEEEooooffff(((()))) nor EEEErrrrrrrroooorrrr(((()))) returns TTTTRRRRUUUUEEEE. Calls C library function cccclllleeeeaaaarrrreeeerrrrrrrr(((()))). RWoffset CCCCuuuurrrrOOOOffffffffsssseeeetttt(); Returns the current position, in bytes from the start of the file, of the file pointer. RWBoolean EEEEooooffff(); Returns TTTTRRRRUUUUEEEE if an end-of-file has been encountered. RWBoolean EEEErrrraaaasssseeee(); Erases the contents but does not close the file. Returns TTTTRRRRUUUUEEEE if the operation was successful. RWBoolean EEEErrrrrrrroooorrrr(); Returns TTTTRRRRUUUUEEEE if a file I/O error has occurred as determined by a call to the C library function ffffeeeerrrrrrrroooorrrr(((()))). RWBoolean EEEExxxxiiiissssttttssss(); Returns TTTTRRRRUUUUEEEE if the file exists. RWBoolean FFFFlllluuuusssshhhh(); Perform any pending I/O operations. Returns TTTTRRRRUUUUEEEE if successful. const char* GGGGeeeettttNNNNaaaammmmeeee(); Returns the file name. PPPPaaaaggggeeee 2222 RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++)))) RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++)))) FILE* GGGGeeeettttSSSSttttrrrreeeeaaaammmm(); Returns the FFFFIIIILLLLEEEE**** that underlies the RRRRWWWWFFFFiiiilllleeee interface. Provided for users who need to "get under the hood" for system-dependent inquiries, etc. DDDDoooo nnnnooootttt uuuusssseeee ttttoooo aaaalllltttteeeerrrr tttthhhheeee ssssttttaaaatttteeee ooooffff tttthhhheeee ffffiiiilllleeee!!!! RWBoolean IIIIssssEEEEmmmmppppttttyyyy(); Returns TTTTRRRRUUUUEEEE if the file contains no data, FFFFAAAALLLLSSSSEEEE otherwise. RWBoolean iiiissssVVVVaaaalllliiiidddd() const; Returns TTTTRRRRUUUUEEEE if the file was successfully opened, FFFFAAAALLLLSSSSEEEE otherwise. RWBoolean RRRReeeeaaaadddd(char& c); RWBoolean RRRReeeeaaaadddd(wchar_t& wc); RWBoolean RRRReeeeaaaadddd(short& i); RWBoolean RRRReeeeaaaadddd(int& i); RWBoolean RRRReeeeaaaadddd(long& i); RWBoolean RRRReeeeaaaadddd(unsigned char& c); RWBoolean RRRReeeeaaaadddd(unsigned short& i); RWBoolean RRRReeeeaaaadddd(unsigned int& i); RWBoolean RRRReeeeaaaadddd(unsigned long& i); RWBoolean RRRReeeeaaaadddd(float& f); RWBoolean RRRReeeeaaaadddd(double& d); Reads the indicated built-in type. Returns TTTTRRRRUUUUEEEE if the read is successful. RWBoolean RRRReeeeaaaadddd(char* i, size_t count); RWBoolean RRRReeeeaaaadddd(wchar_t* i, size_t count); RWBoolean PPPPaaaaggggeeee 3333 RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++)))) RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++)))) RRRReeeeaaaadddd(short* i, size_t count); RWBoolean RRRReeeeaaaadddd(int* i, size_t count); RWBoolean RRRReeeeaaaadddd(long* i, size_t count); RWBoolean RRRReeeeaaaadddd(unsigned char* i, size_t count); RWBoolean RRRReeeeaaaadddd(unsigned short* i,size_t count); RWBoolean RRRReeeeaaaadddd(unsigned int* i, size_t count); RWBoolean RRRReeeeaaaadddd(unsigned long* i, size_t count); RWBoolean RRRReeeeaaaadddd(float* i, size_t count); RWBoolean RRRReeeeaaaadddd(double* i, size_t count); Reads ccccoooouuuunnnntttt instances of the indicated built-in type into a block pointed to by iiii. Returns TTTTRRRRUUUUEEEE if the read is successful. Note that you are responsible for declaring iiii and for allocating the necessary storage before calling this function. RWBoolean RRRReeeeaaaadddd(char* string); Reads a character string, including the terminating null character, into a block pointed to by ssssttttrrrriiiinnnngggg. Returns TTTTRRRRUUUUEEEE if the read is successful. Note that you are responsible for declaring ssssttttrrrriiiinnnngggg and for allocating the necessary storage before calling this function. Beware of overflow when using this function. RWBoolean SSSSeeeeeeeekkkkTTTToooo(RWoffset offset); Repositions the file pointer to ooooffffffffsssseeeetttt bytes from the start of the file. Returns TTTTRRRRUUUUEEEE if the operation is successful. RWBoolean SSSSeeeeeeeekkkkTTTTooooBBBBeeeeggggiiiinnnn(); Repositions the file pointer to the start of the file. Returns TTTTRRRRUUUUEEEE if the operation is successful. RWBoolean SSSSeeeeeeeekkkkTTTTooooEEEEnnnndddd(); PPPPaaaaggggeeee 4444 RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++)))) RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++)))) Repositions the file pointer to the end of the file. Returns TTTTRRRRUUUUEEEE if the operation is successful. RWBoolean WWWWrrrriiiitttteeee(char i); RWBoolean WWWWrrrriiiitttteeee(wchar_t i); RWBoolean WWWWrrrriiiitttteeee(short i); RWBoolean WWWWrrrriiiitttteeee(int i); RWBoolean WWWWrrrriiiitttteeee(long i); RWBoolean WWWWrrrriiiitttteeee(unsigned char i); RWBoolean WWWWrrrriiiitttteeee(unsigned short i); RWBoolean WWWWrrrriiiitttteeee(unsigned int i); RWBoolean WWWWrrrriiiitttteeee(unsigned long i); RWBoolean WWWWrrrriiiitttteeee(float f); RWBoolean WWWWrrrriiiitttteeee(double d); Writes the appropriate built-in type. Returns TTTTRRRRUUUUEEEE if the write is successful. RWBoolean WWWWrrrriiiitttteeee(const char* i, size_t count); RWBoolean WWWWrrrriiiitttteeee(const wchar_t* i, size_t count); RWBoolean WWWWrrrriiiitttteeee(const short* i, size_t count); RWBoolean WWWWrrrriiiitttteeee(const int* i, size_t count); RWBoolean WWWWrrrriiiitttteeee(const long* i, size_t count); RWBoolean WWWWrrrriiiitttteeee(const unsigned char* i, size_t count); RWBoolean WWWWrrrriiiitttteeee(const unsigned short* i,size_t count); RWBoolean WWWWrrrriiiitttteeee(const unsigned int* i, size_t count); RWBoolean WWWWrrrriiiitttteeee(const unsigned long* i, size_t count); RWBoolean WWWWrrrriiiitttteeee(const float* i, size_t count); RWBoolean WWWWrrrriiiitttteeee(const double* i, size_t count); PPPPaaaaggggeeee 5555 RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++)))) RRRRWWWWFFFFiiiilllleeee((((3333CCCC++++++++)))) Writes ccccoooouuuunnnntttt instances of the indicated built-in type from a block pointed to by iiii. Returns TTTTRRRRUUUUEEEE if the write is successful. RWBoolean WWWWrrrriiiitttteeee(const char* string); Writes a character string, iiiinnnncccclllluuuuddddiiiinnnngggg tttthhhheeee tttteeeerrrrmmmmiiiinnnnaaaattttiiiinnnngggg nnnnuuuullllllll cccchhhhaaaarrrraaaacccctttteeeerrrr, from a block pointed to by ssssttttrrrriiiinnnngggg. Returns TTTTRRRRUUUUEEEE if the write is successful. Beware of non-terminated strings when using this function. SSSSttttaaaattttiiiicccc PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss static RWBoolean EEEExxxxiiiissssttttssss(const char* filename, int mode = F_OK); Returns TTTTRRRRUUUUEEEE if a file with name ffffiiiilllleeeennnnaaaammmmeeee exists and may be accessed according to the mmmmooooddddeeee specified. The mmmmooooddddeeee may be OOOORRRRed together from one or more of: FFFF____OOOOKKKK: "Exists" (Implied by any of the others) XXXX____OOOOKKKK: "Executable or searchable" WWWW____OOOOKKKK: "Writable" RRRR____OOOOKKKK: "Readable" If your compiler or operating system does not support the POSIX aaaacccccccceeeessssssss(((()))) function, then mode XXXX____OOOOKKKK will always return FFFFAAAALLLLSSSSEEEE. PPPPaaaaggggeeee 6666